package org.jeecg.modules.ParameterModule.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.ParameterModule.entity.*;
import org.jeecg.modules.ParameterModule.service.CategoryInfoService;
import org.jeecg.modules.ParameterModule.service.FormalCategoryInfoService;
import org.jeecg.modules.ParameterModule.service.TestPlateInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.Future;

/**
 * 后台类别配置
 * */
@Api(tags="后台正式类别配置")
@RestController
@RequestMapping("/admin/formal/parameter")
@Slf4j
public class FormalCategoryInfoController {
    //启用品类
    @Autowired
    private FormalCategoryInfoService parameterService;
    //品类测试区
    @Autowired
    private CategoryInfoService testparameterService;
    //测试区版号
    @Autowired
    private TestPlateInfoService banhao_parameterService;

    /**
     * 根据id查询类别品类详情
     * @return
     */
    @GetMapping(value = "/query_testcategoryDetail")
    public Result<?> query_testcategoryDetail(@RequestParam(name="id")String category_id){
        MlccCategoryTestInfo datainfo = parameterService.select_testcategoryDetail(category_id);
        if(datainfo!=null){
            return Result.ok(datainfo);
        }else{
            return Result.error("未找到对应数据");
        }
    }

    /**
     * 修改正式品类或版号的状态---根据id
     * @param
     * @return boolean
     */
    @PutMapping(value = "/edit_category_status")
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    public Result<?> edit_category_status(@RequestBody Map<String,Object> params) {
        String category_id = params.get("category_id").toString();
        String status = params.get("status").toString();
        try {
            int code = parameterService.edit_category_status(category_id,status);
            if(code>0){
                if("2".equals(status)){
                    return Result.ok("下架成功");
                }else {
                    return Result.ok("上架成功！");
                }
            }else {
                return Result.error("操作失败");
            }
        }catch (Exception e){
            return Result.error("操作失败，参数错误");
        }
    }

    /**
     * 根据品类id统计数据
     * @return
     */
    @GetMapping(value = "/count_data_pingleiId")
    public Result<?> count_data_pingleiId(@RequestParam(name="category_id")String category_id){
        CountDataInfo countDataInfo = new CountDataInfo();
        int xiuzinum1 = parameterService.count_xiuzi_color(category_id);
        int xiuzinum2 = parameterService.count_xiuzi_font(category_id);
        int xiuzinum3 = parameterService.count_xiuzi_img(category_id);
        int xiuzinum4 = parameterService.count_xiuzi(category_id);
        countDataInfo.setDingzhiNum(parameterService.count_dingzhi(category_id));
        countDataInfo.setHuchiNum(parameterService.count_huchi(category_id));
        countDataInfo.setXiuziNum(xiuzinum1+xiuzinum2+xiuzinum3+xiuzinum4);
        countDataInfo.setZhuangseNum(parameterService.count_zhuangse(category_id));
        countDataInfo.setJingtiNum(parameterService.count_jing_bodysize(category_id));
        countDataInfo.setChengNum(parameterService.count_cheng_bodysize(category_id));
        countDataInfo.setFanxiuNum(parameterService.count_fanxiu(category_id));
        countDataInfo.setGongyiNum(parameterService.count_gongyi(category_id));
        return Result.ok(countDataInfo);
    }

    /**
     * 总后台查询+测试定制项下的参数列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_dignzhipartmer")
    public Result<?> query_test_dignzhipartmer(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                               @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                               String topcategory_id,String module_id,String queryName) {
        Page<MlccCategoryTestInfo> page = new Page<MlccCategoryTestInfo>(pageNo, pageSize);
        IPage<MlccCategoryTestInfo> pageList = parameterService.query_testCanshuPageList(page,topcategory_id,module_id,queryName);
        return Result.ok(pageList);
    }
    /**
     * 根据品类id查询定制项+正式
     * @return
     */
    @GetMapping(value = "/query_dingzhiBypingleiId")
    public Result<?> query_dingzhiBypingleiId(@RequestParam(name="category_id")String category_id){
        List<SmalltemplateTestInfo> datalist = parameterService.query_dingzhiBycategoryId(category_id);
        if(datalist.size()>0){
            return Result.ok(datalist);
        }else{
            return Result.error("未找到对应数据");
        }
    }

    /**
     * 根据定制id查询定制项
     * @return
     */
    @GetMapping(value = "/query_dingzhiBydingzhiId")
    public Result<?> query_dingzhiBydingzhiId(@RequestParam(name="dinghzi_id")String dinghzi_id){
        SmalltemplateTestInfo datainfo = parameterService.query_dingzhiBydingzhId(dinghzi_id);
        if(datainfo!=null){
            return Result.ok(datainfo);
        }else{
            return Result.error("未找到对应数据");
        }
    }

    /**
     * 总后台查询+测试品类互斥项
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_pingleiHuchi")
    public Result<?> query_test_pingleiHuchi(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                             @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                             String topid,String queryName,String queryTime) {
        Page<MutexTestInfo> page = new Page<MutexTestInfo>(pageNo, pageSize);
        IPage<MutexTestInfo> pageList = parameterService.query_testHuchiPageList(page,topid,queryName,queryTime);
        if(pageList!=null || pageList.getRecords().size()>0){
            for (int i=0;i<pageList.getRecords().size();i++){
                String categoryNames ="";
                if(pageList.getRecords().get(i).getCategoryOther()!=null){
                    String[] idS = pageList.getRecords().get(i).getCategoryOther().split(",");
                    for (String s:idS){
                        MlccCategoryTestInfo datainfo = parameterService.select_testcategoryDetail(s);
                        if(datainfo!=null){
                            categoryNames+=datainfo.getCategoryName()+",";
                        }
                    }
                }
                if(categoryNames==null || "".equals(categoryNames)){
                    pageList.getRecords().get(i).setCategoryOtherName("");
                }else {
                    pageList.getRecords().get(i).setCategoryOtherName(categoryNames.substring(0,categoryNames.length()-1));
                }

            }
        }
        return Result.ok(pageList);
    }
    /**
     * 总后台查询+测试部位列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_xiuzi_locationlist")
    public Result<?> test_xiuzi_locationlist(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                             @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                             String category_id,String queryName,String queryTime) {
        Page<CategoryLocationTestInfo> page = new Page<CategoryLocationTestInfo>(pageNo, pageSize);
        IPage<CategoryLocationTestInfo> pageList = parameterService.query_testlocaltionPageList(page,category_id,queryName,queryTime);
        return Result.ok(pageList);
    }
    /**
     * 总后台查询+测试颜色列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_xiuzi_colorlist")
    public Result<?> test_xiuzi_colorlist(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                          @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                          String category_id,String queryName,String queryTime) {
        Page<EmbroideredColorTestInfo> page = new Page<EmbroideredColorTestInfo>(pageNo, pageSize);
        IPage<EmbroideredColorTestInfo> pageList = parameterService.query_testColorPageList(page,category_id,queryName,queryTime);
        return Result.ok(pageList);
    }
    /**
     * 总后台查询+绣字图片列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_xiuzi_imglist")
    public Result<?> test_xiuzi_imglist(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                        @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                        String category_id,String queryName,String queryTime) {
        Page<EmbroideredFontTestInfo> page = new Page<EmbroideredFontTestInfo>(pageNo, pageSize);
        IPage<EmbroideredFontTestInfo> pageList = parameterService.query_testImgPageList(page,category_id,queryName,queryTime);
        return Result.ok(pageList);
    }
    /**
     * 总后台查询+测试字体列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_xiuzi_fontlist")
    public Result<?> test_xiuzi_fontlist(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                         @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                         String category_id,String queryName,String queryTime) {
        Page<EmbroideredFontTestInfo> page = new Page<EmbroideredFontTestInfo>(pageNo, pageSize);
        IPage<EmbroideredFontTestInfo> pageList = parameterService.query_testFontPageList(page,category_id,queryName,queryTime);
        return Result.ok(pageList);
    }
    /**
     * 总后台查询+身体尺寸
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_jinti_bodysize")
    public Result<?> test_jinti_bodysize(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                         @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                         String category_id,String type,String queryName,String queryTime) {
        Page<BodySizeTestInfo> page = new Page<BodySizeTestInfo>(pageNo, pageSize);
        IPage<BodySizeTestInfo> pageList = parameterService.query_testBodySizePageList(page,type,category_id,queryName,queryTime);
        return Result.ok(pageList);
    }
    /**
     * 总后台查询+返修尺寸
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_fanxiu_bodysize")
    public Result<?> test_fanxiu_bodysize(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                          @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                          String category_id,String queryName,String queryTime) {
        Page<CategoryFanxiuTestInfo> page = new Page<CategoryFanxiuTestInfo>(pageNo, pageSize);
        IPage<CategoryFanxiuTestInfo> pageList = parameterService.query_testFanxiuSizePageList(page,category_id,queryName,queryTime);
        if(pageList.getRecords().size()>0){
            for (int i=0;i<pageList.getRecords().size();i++){
                pageList.getRecords().get(i).setFanwei(pageList.getRecords().get(i).getMin()+"至"+pageList.getRecords().get(i).getMax());
            }
        }
        return Result.ok(pageList);
    }
    /**
     * 总后台查询+根据类型查询测试类别列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_categoryinfoListBytype")
    public Result<?> test_categoryinfoListBytype(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                                 @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                                 String category_id,String type,String queryName,String queryCode) {
        Page<MlccCategoryTestInfo> page = new Page<MlccCategoryTestInfo>(pageNo, pageSize);
        IPage<MlccCategoryTestInfo> pageList = parameterService.query_testCategoryPageListBytype(page,category_id,type,queryName,queryCode);
        return Result.ok(pageList);
    }

    /**
     * 根据品类id查询启用记录
     * @return
     */
    @GetMapping(value = "/query_qiyongRecrod")
    public Result<?> query_QiyongRecrod(@RequestParam(name="category_id")String category_id){
        System.out.println("==金磊=="+category_id);
        List<QiyongListInfo> datalist = parameterService.query_QiyongRecrod(category_id);
        if(datalist.size()>0){
            return Result.ok(datalist);
        }else{
            return Result.error("未找到对应数据");
        }
    }
    /**
     * 总后台查询+撞色列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_zhuangselist")
    public Result<?> test_zhuangselist(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                       @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                       String category_id,String queryName,String queryTime) {
        Page<ContrastcolorTestInfo> page = new Page<ContrastcolorTestInfo>(pageNo, pageSize);
        IPage<ContrastcolorTestInfo> pageList = parameterService.query_testzhuangsePageList(page,category_id,queryName,queryTime);
        return Result.ok(pageList);
    }
    /**
     * 启用草稿件
     * @param
     * @return boolean
     */
    @PostMapping(value = "/right_enable_caogao")
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    public Result<?> right_enable_caogao(@RequestBody Map<String,Object> params) {
        String category_id = params.get("category_id").toString();//获取品类id
        System.out.println("品类启用传的测试品类id===" + category_id);
        //获取登录用户信息
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String sys_org_code = sysUser.getOrgCode();
        String create_by = sysUser.getUsername();
//        try {
            if(category_id==null || "".equals(category_id)){
                return Result.error("id不能为空");
            }
            /**正式品类赋值*/
            String zhengshi_categoryId = "",zhengshi_categoryName="";
            //根据品类id查询品类详情----查测试的
            MlccCategoryTestInfo testpinglei = testparameterService.select_testcategoryDetail(category_id);
            String issize = testpinglei.getIsSize().toString();//拿到测试是否需要体型
            String category_code = testpinglei.getCategoryCode();
            MlccCategoryInfo panduan_pinglei = parameterService.select_zscategoryDetail(category_code);//根据品类编号查询品类
            if(panduan_pinglei!=null){
                //先判断该品类是否上架
                if(panduan_pinglei.getStatus()==0){
                    return Result.error("请先下架该品类，然后才能再次启用");
                }
                Long startTs1 = System.currentTimeMillis(); // 当前时间戳
                /**正式品类id下的参数*/
                String formalcategory_id = panduan_pinglei.getId().toString();
                zhengshi_categoryName = panduan_pinglei.getCategoryName();
                zhengshi_categoryId = panduan_pinglei.getId().toString();
                System.out.println("查询到正式品类id=="+formalcategory_id);
                //根据品类id查询定制项
                List<SmalltemplateTestInfo> test_dingzhilist = banhao_parameterService.query_dingzhiBycategoryId(formalcategory_id);
                //根据品类id查询定制项下的参数
                List<MlccCategoryTestInfo> test_canshulist = banhao_parameterService.query_AllcanshuBypingleiId(formalcategory_id);
                //根据品类id查询互斥项
                List<MutexTestInfo> test_huchilist = banhao_parameterService.query_AllhuchiBypingleiId(formalcategory_id);
                //根据品类id查询绣字部位
                List<CategoryLocationTestInfo> test_xuzilist1 = banhao_parameterService.query_Allxiuzi1BypingleiId(formalcategory_id);
                //根据品类id查询绣字颜色
                List<EmbroideredColorTestInfo> test_xuzilist2 = banhao_parameterService.query_AllxiuziColorBypingleiId(formalcategory_id);
                //根据品类id查询绣字图片
                List<EmbroideredFontTestInfo> test_xuzilist3 = banhao_parameterService.query_AllxiuziFontBypingleiId(formalcategory_id);
                //根据品类id查询撞色
                List<ContrastcolorTestInfo> test_zhuangselist = banhao_parameterService.query_AllzhuangseBypingleiId(formalcategory_id);
                //根据品类id查询净体尺寸
                List<BodySizeTestInfo> test_bodysizelist1 = banhao_parameterService.query_AlljingtiBodysizeBypingleiId(formalcategory_id);
                //根据品类id查询返修
                List<CategoryFanxiuTestInfo> test_fanxiulist = banhao_parameterService.query_AllFanxiuBypingleiId(formalcategory_id);
                //根据品类id查询工艺类型
                List<MlccCategoryTestInfo> test_gongyilist = banhao_parameterService.query_AllGongyiBypingleiId(formalcategory_id);
                //根据品类id查询所有系统加急
                List<AddSystemPriceInfo> test_syspricelist = banhao_parameterService.query_AllsyspriceBypingleiId(formalcategory_id,1);
                List<AddSystemPriceInfo> test_syspricelist2 = banhao_parameterService.query_AllsyspriceBypingleiId(formalcategory_id,0);
                //根据品类id查询所有绣字高度
                List<EmbroidedHeightInfo> test_allxiuziHeightlist = banhao_parameterService.query_AllHeightBypingleiId(formalcategory_id);

                /**根据测试品类id查询测试数据*/
                //根据品类id查询定制项
                List<SmalltemplateTestInfo> dingzhilist = testparameterService.query_dingzhiBycategoryId(category_id);
                //根据品类id查询定制项下的参数
                List<MlccCategoryTestInfo> canshulist = parameterService.query_AllcanshuBypingleiId(category_id);
                //根据品类id查询互斥项
                List<MutexTestInfo> huchilist = parameterService.query_AllhuchiBypingleiId(category_id);
                //根据品类id查询绣字部位
                List<CategoryLocationTestInfo> xuzilist1 = parameterService.query_Allxiuzi1BypingleiId(category_id);
                //根据品类id查询绣字颜色
                List<EmbroideredColorTestInfo> xuzilist2 = parameterService.query_AllxiuziColorBypingleiId(category_id);
                //根据品类id查询绣字图片
                List<EmbroideredFontTestInfo> xuzilist3 = parameterService.query_AllxiuziFontBypingleiId(category_id);
                //根据品类id查询撞色
                List<ContrastcolorTestInfo> zhuangselist = parameterService.query_AllzhuangseBypingleiId(category_id);
                //根据品类id查询净体尺寸
                List<BodySizeTestInfo> bodysizelist1 = parameterService.query_AlljingtiBodysizeBypingleiId(category_id);
                //根据品类id查询返修
                List<CategoryFanxiuTestInfo> fanxiulist = parameterService.query_AllFanxiuBypingleiId(category_id);
                //根据品类id查询工艺类型
                List<MlccCategoryTestInfo> gongyilist = parameterService.query_AllGongyiBypingleiId(category_id);
                //根据品类id查询所有系统加急
                List<AddSystemPriceInfo> syspricelist = parameterService.query_AllsyspriceBypingleiId(category_id,1);
                List<AddSystemPriceInfo> syspricelist2 = parameterService.query_AllsyspriceBypingleiId(category_id,0);
                //根据品类id查询所有绣字高度-测试
                List<EmbroidedHeightInfo> xiuziHeightlist = parameterService.query_AllxiuziHeightBypingleiId(category_id);

                /**
                 * 定制项、定制项下的参数、撞色、返修、收费服务这几个不能全删除
                 * */
                /**循环删除正式的所有参数*/
                if (test_canshulist.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (MlccCategoryTestInfo testobject : test_canshulist) {
                        MlccCategoryInfo zs_canshuDetail = parameterService.querycanshuDetailByCode(testobject.getCategoryCode(),category_id,testobject.getParentId(),1,1);
                        if(zs_canshuDetail != null ){
                            System.out.println("删除1==="+testobject.getId().toString());
                            code = parameterService.delete_dingzhi_canshu(testobject.getId().toString());
                        }
                    }
                    System.out.println("删除正式参数==" + code);
                }
                if (test_dingzhilist.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (SmalltemplateTestInfo testobject : test_dingzhilist) {
                        ModuleSmalltemplateInfo zs_dingzihDetail = parameterService.queryDingzhiDetailByName(testobject.getParameter(),category_id,1,1);
                        if(zs_dingzihDetail !=null ){
                            System.out.println("删除2==="+testobject.getId().toString());
                            code = parameterService.delete_dingzhi(testobject.getId().toString());
                        }
                    }
                    System.out.println("删除定制项==" + code);
                }
                if (test_huchilist.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (MutexTestInfo testobject : test_huchilist) {
                        code = parameterService.delete_huchi(testobject.getId().toString());
                    }
                    System.out.println("删除互斥项==" + code);
                }
                if (test_xuzilist1.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (CategoryLocationTestInfo testobject : test_xuzilist1) {
                        code = parameterService.delete_xiuzi_location(testobject.getId().toString());
                    }
                    System.out.println("删除绣字部位==" + code);
                }
                if (test_xuzilist2.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (EmbroideredColorTestInfo testobject : test_xuzilist2) {
                        code = parameterService.delete_xiuzi_color(testobject.getId().toString());
                    }
                    System.out.println("删除绣字颜色==" + code);
                }
                if (test_xuzilist3.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (EmbroideredFontTestInfo testobject : test_xuzilist3) {
                        code = parameterService.delete_xiuzi_fontImg(testobject.getId().toString());
                    }
                    System.out.println("删除绣字字体图片==" + code);
                }
                if (test_allxiuziHeightlist.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (EmbroidedHeightInfo testobject : test_allxiuziHeightlist) {
                        code = banhao_parameterService.delete_xiuzi_height(testobject.getId().toString());
                    }
                    System.out.println("删除绣字高度=正式的=" + code);
                }
                if (test_zhuangselist.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (ContrastcolorTestInfo testobject : test_zhuangselist) {
                        ContrastcolorInfo test_zhuangse = parameterService.queryZhuangseDetailByCode(testobject.getCode(),category_id,1,1);
                        if(test_zhuangse!=null){
                            ContrastcolorInfo zs_zhuangse = parameterService.queryZhuangseDetailByCode(test_zhuangse.getCode(),formalcategory_id,0,1);
                            if(zs_zhuangse!=null){
                                System.out.println("删除3==="+testobject.getId().toString());
                                code = parameterService.delete_zhuangse(zs_zhuangse.getId().toString());
                            }
                        }
                    }
                    System.out.println("删除撞色==" + code);
                }
                if (test_bodysizelist1.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (BodySizeTestInfo testobject : test_bodysizelist1) {
                        code = parameterService.delete_testbodySize(testobject.getId().toString());
                    }
                    System.out.println("删除尺寸==" + code);
                }
                if (test_fanxiulist.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (CategoryFanxiuTestInfo testobject : test_fanxiulist) {
                        CategoryFanxiuInfo test_fanxiu = parameterService.queryfanxiuDetailByName(testobject.getBodySizename(),category_id,1,1);
                        if(test_fanxiu!=null){
                            System.out.println("删除4==="+testobject.getId().toString());
                            code = parameterService.delete_testfanxiuSize(testobject.getId().toString());
                        }
                    }
                    System.out.println("删除返修==" + code);
                }
//                if (test_gongyilist.size() > 0) {
//                    //循环删除
//                    int code = 0;
//                    for (MlccCategoryTestInfo testobject : test_gongyilist) {
//                        code = parameterService.delete_testcategory(testobject.getId().toString());
//                    }
//                    System.out.println("删除工艺类型==" + code);
//                }
                if (test_syspricelist.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (AddSystemPriceInfo testobject : test_syspricelist) {
                        AddSystemPriceInfo test_fanxiu = parameterService.queryshTypeDetailByName(testobject.getPremiumItem(),category_id,1,1);
                        if(test_fanxiu!=null){
                            System.out.println("删除5==="+testobject.getId().toString());
                            code = parameterService.del_fomal_syspriceinfo(testobject.getId().toString());
                        }
                    }
                    System.out.println("删除系统加急==" + code);
                }
                if (test_syspricelist2.size() > 0) {
                    //循环删除
                    int code = 0;
                    for (AddSystemPriceInfo testobject : test_syspricelist2) {
                        AddSystemPriceInfo test_fanxiu = parameterService.queryshoufeiDetailByName(testobject.getPremiumItem(),category_id,1,1);
                        if(test_fanxiu!=null){
                            System.out.println("删除6==="+testobject.getId().toString());
                            code = parameterService.del_fomal_syspriceinfo(testobject.getId().toString());
                        }
                    }
                    System.out.println("删除系统加急2==" + code);
                }

                int code2 = 0,code3=0,code4=0,code5=0,code6=0,code7=0,code8=0,code9=0,code10=0,code66=0,code11=0,code67=0;
                if(dingzhilist.size()>0){
                    for (int i=0;i<dingzhilist.size();i++){
                        //根据定制项的名称和类别id查询定制项
                        ModuleSmalltemplateInfo zs_dingzihDetail = parameterService.queryDingzhiDetailByName(dingzhilist.get(i).getParameter(),formalcategory_id,0,0);
                        if(zs_dingzihDetail !=null ){
                            //循环执行修改定制项
                            System.out.println("走修改1==="+zs_dingzihDetail.getId());
                            SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                            datainfo.setCode(dingzhilist.get(i).getCode());
                            datainfo.setParameter(dingzhilist.get(i).getParameter());
                            datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                            datainfo.setRemark(dingzhilist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(zs_dingzihDetail.getId());
                            code2 = parameterService.change_dingzhi(datainfo);
                        }else {
                            //循环添加定制项
                            System.out.println("走增加1==="+dingzhilist.get(i).getParameter());
                            SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                            datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                            datainfo.setCategoryId(formalcategory_id);
                            datainfo.setCode(dingzhilist.get(i).getCode());
                            datainfo.setParameter(dingzhilist.get(i).getParameter());
                            datainfo.setImgs(dingzhilist.get(i).getImgs());
                            datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                            datainfo.setIstype(dingzhilist.get(i).getIstype());
                            datainfo.setRemark(dingzhilist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code2 = parameterService.add_dingzhi(datainfo);
                        }
                    }
                }

                if(canshulist.size()>0){
                    for (int i=0;i<canshulist.size();i++){
                        String praent_id = "";
                        SmalltemplateTestInfo ceshidingdatainfo = testparameterService.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                        if(ceshidingdatainfo!=null){
                            //查询新增的定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = parameterService.query_dingzhiBycategoryId(formalcategory_id);
                            if(zsdingzhi_datalist.size()>0){
                                for (int k=0;k<zsdingzhi_datalist.size();k++){
                                    if(ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                        praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                    }
                                }
                            }
                        }
                        MlccCategoryInfo zs_canshu = parameterService.querycanshuDetailByCode(canshulist.get(i).getCategoryCode(),formalcategory_id,praent_id,0,0);
                        if(zs_canshu!=null){
                            //循环修改定制项下的参数
                            System.out.println("走修改2==="+zs_canshu.getId());
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                            datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                            datainfo.setParentId(praent_id);//正式的上级id
                            datainfo.setImg(canshulist.get(i).getImg());
                            datainfo.setTopid(formalcategory_id);
                            datainfo.setNumbers(canshulist.get(i).getNumbers());
                            datainfo.setIsType(0);
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(zs_canshu.getId());
                            code3 = parameterService.change_dingzhi_canshu(datainfo);
                        }else {
                            //循环添加定制项下的参数
                            System.out.println("走增加2==="+praent_id);
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                            datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                            datainfo.setParentId(praent_id);//正式的上级id
                            datainfo.setImg(canshulist.get(i).getImg());
                            datainfo.setTopid(formalcategory_id);
                            datainfo.setNumbers(canshulist.get(i).getNumbers());
                            datainfo.setIsType(0);
                            datainfo.setCost("0");
                            datainfo.setTeamPrice2("0");
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code3 = parameterService.add_dingzhi_canshu(datainfo);
                        }
                    }
                }
                if(xuzilist1.size()>0){
                    for (int i=0;i<xuzilist1.size();i++){
                        //循环添加绣字部位
                        CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                        datainfo.setCode(xuzilist1.get(i).getCode());
                        datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setRemark(xuzilist1.get(i).getRemark());
                        datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code5 = parameterService.add_xiuzi_location(datainfo);
                    }
                }
                if(xuzilist2.size()>0){
                    for (int i=0;i<xuzilist2.size();i++){
                        //循环添加绣字颜色
                        EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                        datainfo.setCode(xuzilist2.get(i).getCode());
                        datainfo.setColorName(xuzilist2.get(i).getColorName());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                        datainfo.setRemark(xuzilist2.get(i).getRemark());
                        datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code6 = parameterService.add_xiuzi_color(datainfo);
                    }
                }
                if(xuzilist3.size()>0){
                    for (int i=0;i<xuzilist3.size();i++){
                        //循环添加绣字字体
                        EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                        datainfo.setCode(xuzilist3.get(i).getCode());
                        datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                        datainfo.setRemark(xuzilist3.get(i).getRemark());
                        datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                        datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                        datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code66 = parameterService.add_xiuzi_fontImg(datainfo);
                    }
                }
                if(xiuziHeightlist.size()>0){
                    for (int i=0;i<xiuziHeightlist.size();i++){
                        //循环添加绣字高度
                        EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                        datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                        datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code67 = banhao_parameterService.add_xiuzi_height(datainfo);
                    }
                }
                if(zhuangselist.size()>0){
                    for (int i=0;i<zhuangselist.size();i++){
                        ContrastcolorInfo zs_zhuangse = parameterService.queryZhuangseDetailByCode(zhuangselist.get(i).getCode(),formalcategory_id,0,0);
                        String praent_id = "",firstId="";
                        SmalltemplateTestInfo ceshidingdatainfo = testparameterService.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                        if(ceshidingdatainfo!=null){
                            //查询新增的定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = parameterService.query_dingzhiBycategoryId(formalcategory_id);
                            if(zsdingzhi_datalist.size()>0){
                                for (int k=0;k<zsdingzhi_datalist.size();k++){
                                    if(ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                        praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                    }
                                }
                            }
                        }
                        //根据类别id查询类别详情
                        MlccCategoryTestInfo leibiedatainfo1 = testparameterService.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                        if(leibiedatainfo1!=null){
                            MlccCategoryInfo zsleibie = parameterService.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),formalcategory_id,praent_id);
                            if(zsleibie!=null){
                                firstId = zsleibie.getId().toString();
                            }
                        }
                        if(zs_zhuangse!=null){
                            //循环修改撞色
                            System.out.println("走修改3==="+praent_id+"==="+firstId);
                            ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                            datainfo.setCode(zhuangselist.get(i).getCode());
                            datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                            datainfo.setCategoryId(firstId);
                            datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                            datainfo.setDingzhiId(praent_id);
                            datainfo.setRemark(zhuangselist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(zs_zhuangse.getId());
                            code7 = parameterService.change_zhuangse(datainfo);
                        }else {
                            //循环添加撞色
                            System.out.println("走增加3==="+praent_id+"==="+firstId);
                            ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                            datainfo.setTopId(formalcategory_id);
                            datainfo.setCode(zhuangselist.get(i).getCode());
                            datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                            datainfo.setCategoryId(firstId);
                            datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                            datainfo.setDingzhiId(praent_id);
                            datainfo.setRemark(zhuangselist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code7 = parameterService.add_zhuangse(datainfo);
                        }
                    }
                }
                if(bodysizelist1.size()>0){
                    for (int i=0;i<bodysizelist1.size();i++){
                        //循环添加身体尺寸
                        BodySizeTestInfo datainfo = new BodySizeTestInfo();
                        datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                        datainfo.setUnit(bodysizelist1.get(i).getUnit());
                        datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                        datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                        datainfo.setMax(bodysizelist1.get(i).getMax());
                        datainfo.setMin(bodysizelist1.get(i).getMin());
                        datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code8 = parameterService.add_testbodySize(datainfo);
                    }
                }
                if(fanxiulist.size()>0){
                    for (int i=0;i<fanxiulist.size();i++){
                        CategoryFanxiuInfo zs_fanxiu = parameterService.queryfanxiuDetailByName(fanxiulist.get(i).getBodySizename(),formalcategory_id,0,0);
                        if(zs_fanxiu!=null){
                            //循环修改返修
                            System.out.println("走修改4==="+zs_fanxiu.getId());
                            CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                            datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                            datainfo.setCode(fanxiulist.get(i).getCode());
                            datainfo.setUnit(fanxiulist.get(i).getUnit());
                            datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                            datainfo.setMax(fanxiulist.get(i).getMax());
                            datainfo.setMin(fanxiulist.get(i).getMin());
                            datainfo.setRemark(fanxiulist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(zs_fanxiu.getId());
                            code9 = parameterService.change_fanxiu(datainfo);
                        }else {
                            //循环添加返修
                            System.out.println("走增加4===");
                            CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                            datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                            datainfo.setCode(fanxiulist.get(i).getCode());
                            datainfo.setUnit(fanxiulist.get(i).getUnit());
                            datainfo.setCategoryId(formalcategory_id);
                            datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                            datainfo.setMax(fanxiulist.get(i).getMax());
                            datainfo.setMin(fanxiulist.get(i).getMin());
                            datainfo.setRemark(fanxiulist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code9 = parameterService.add_testFanxiuSize(datainfo);
                        }
                    }
                }
                if(gongyilist.size()>0){
                    for (int i=0;i<gongyilist.size();i++){
                        //循环添加工艺
                        MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                        MlccCategoryInfo gongyidetail = parameterService.select_canshu_gongyiDetailById(gongyilist.get(i).getCategoryCode(),
                                gongyilist.get(i).getCategoryName(),formalcategory_id,4);//根据品类编号查询品类
                        if(gongyidetail==null || "".equals(gongyidetail)){
                            System.out.println("进来判断这个添加工艺了吗===");
                            datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                            datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                            datainfo.setParentId(gongyilist.get(i).getParentId());
                            datainfo.setImg(gongyilist.get(i).getImg());
                            datainfo.setRemark(gongyilist.get(i).getRemark());
                            datainfo.setTopid(formalcategory_id);
                            datainfo.setIsType(4);
                            datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                            datainfo.setNumbers(gongyilist.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code10 = parameterService.add_category_pinglei2(datainfo);
                            if(code10>0){
                                MlccCategoryInfo gongyidetail2 = parameterService.select_canshuDetailById(gongyilist.get(i).getCategoryCode(),formalcategory_id);//根据品类编号查询品类
                                if(gongyidetail2!=null){
                                    System.out.println("进来判断这个添加工艺了吗22222==="+"===cde==="+code10+"==="+gongyidetail2.getId().toString());
                                    for (int j=0;j<3;j++){
                                        AddSystemPriceInfo addSystemPriceInfo = parameterService.select_addSystempriceInfo(gongyidetail2.getId().toString(),j+"");
                                        if(addSystemPriceInfo==null){
                                            System.out.println("进来判断这个添加工艺了吗33333333==="+gongyidetail2.getId().toString());
                                            parameterService.add_pricesystem_category(gongyidetail2.getId().toString(),j+"","工艺类型售价加工","1",
                                                    create_by,sys_org_code);
                                        }
                                    }
                                }
                            }
                        }else {
                            System.out.println("不是空的添加工艺了=="+"===cde==="+code10+"==="+gongyidetail.getId().toString());
                            for (int j=0;j<3;j++){
                                AddSystemPriceInfo addSystemPriceInfo = parameterService.select_addSystempriceInfo(gongyidetail.getId().toString(),j+"");
                                if(addSystemPriceInfo==null){
                                    System.out.println("不是空的添加工艺了2222==="+gongyidetail.getId().toString());
                                    parameterService.add_pricesystem_category(gongyidetail.getId().toString(),j+"","工艺类型售价加工","1",
                                            create_by,sys_org_code);
                                }
                            }
                        }
                    }
                }
                if(syspricelist.size()>0){
                    for (int i=0;i<syspricelist.size();i++){
                        AddSystemPriceInfo zs_topshoufei = parameterService.queryshTypeDetailByName(syspricelist.get(i).getPremiumItem(),formalcategory_id,0,0);
                        if(zs_topshoufei != null){
                            //循环修改系统加急--上级
                            System.out.println("走修改5==="+zs_topshoufei.getId());
                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                            datainfo.setPremiumItem(syspricelist.get(i).getPremiumItem());
                            datainfo.setPremiumCode(syspricelist.get(i).getPremiumCode());
                            datainfo.setRemark(syspricelist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setPartentId("0");
                            datainfo.setIsTop(1);
                            datainfo.setNumbers(syspricelist.get(i).getNumbers());
                            datainfo.setId(zs_topshoufei.getId());
                            code11 = parameterService.change_shoufei(datainfo);
                        }else {
                            //循环添加系统加急--上级
                            System.out.println("走增加5===");
                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                            datainfo.setPremiumItem(syspricelist.get(i).getPremiumItem());
                            datainfo.setPremiumCode(syspricelist.get(i).getPremiumCode());
                            datainfo.setCategoryId(formalcategory_id);
                            datainfo.setType(syspricelist.get(i).getType());
                            datainfo.setRemark(syspricelist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setPartentId("0");
                            datainfo.setIsTop(1);
                            datainfo.setNumbers(syspricelist.get(i).getNumbers());
                            code11 = parameterService.add_fomal_syspriceinfo(datainfo);
                        }
                    }
                }

                if(syspricelist2.size()>0){
                    for (int i=0;i<syspricelist2.size();i++){
                        //根据编码查询系统加急项
                        String praent_id = "";
                        AddSystemPriceInfo ceshidingdatainfo = testparameterService.query_addsyspriceDetail(syspricelist2.get(i).getPartentId());
                        if(ceshidingdatainfo!=null){
                            //查询新增的上级加急项
                            List<AddSystemPriceInfo> zsdingzhi_datalist = banhao_parameterService.query_AllsyspriceBypingleiId(formalcategory_id,1);
                            if(zsdingzhi_datalist.size()>0){
                                for (int k=0;k<zsdingzhi_datalist.size();k++){
                                    if(ceshidingdatainfo.getPremiumCode().equals(zsdingzhi_datalist.get(k).getPremiumCode())){
                                        praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        break;
                                    }
                                }
                            }
                        }
                        AddSystemPriceInfo zs_shoufei = parameterService.queryshoufeiDetailByName(syspricelist2.get(i).getPremiumItem(),formalcategory_id,0,0);
                        if(zs_shoufei != null){
                            //循环修改系统加急--上级
                            System.out.println("走修改6==="+zs_shoufei.getId());
                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                            datainfo.setPremiumItem(syspricelist2.get(i).getPremiumItem());
                            datainfo.setPremiumCode(syspricelist2.get(i).getPremiumCode());
                            datainfo.setRemark(syspricelist2.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setIsTop(0);
                            datainfo.setNumbers(syspricelist2.get(i).getNumbers());
                            datainfo.setId(zs_shoufei.getId());
                            code11 = parameterService.change_shoufei(datainfo);
                        }else {
                            //循环添加系统加急--下级
                            System.out.println("走增加6==="+praent_id);
                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                            datainfo.setPremiumItem(syspricelist2.get(i).getPremiumItem());
                            datainfo.setPremiumCode(syspricelist2.get(i).getPremiumCode());
                            datainfo.setCategoryId(formalcategory_id);
                            datainfo.setType(syspricelist2.get(i).getType());
                            datainfo.setRemark(syspricelist2.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setPartentId(praent_id);//上级
                            datainfo.setIsTop(0);
                            datainfo.setNumbers(syspricelist2.get(i).getNumbers());
                            code11 = parameterService.add_fomal_syspriceinfo(datainfo);
                        }
                    }
                }

                if(huchilist.size()>0){
                    for (int i=0;i<huchilist.size();i++){
                        //查询新增的定制项
                        String dingzhi1="",dingzhi2="";
                        String firstId = "",secoundId="";
                        List<SmalltemplateTestInfo> zsdingzhi_datalist = parameterService.query_dingzhiBycategoryId(formalcategory_id);
                        SmalltemplateTestInfo ceshidingdatainfo1 = testparameterService.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                        SmalltemplateTestInfo ceshidingdatainfo2 = testparameterService.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                        if(ceshidingdatainfo1!=null){
                            if(zsdingzhi_datalist.size()>0){
                                for (int k=0;k<zsdingzhi_datalist.size();k++){
                                    if(ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                        dingzhi1 = zsdingzhi_datalist.get(k).getId().toString();
                                        break;
                                    }
                                }
                            }
                        }
                        if(ceshidingdatainfo2!=null){
                            if(zsdingzhi_datalist.size()>0){
                                for (int k=0;k<zsdingzhi_datalist.size();k++){
                                    if(ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                        dingzhi2 = zsdingzhi_datalist.get(k).getId().toString();
                                        break;
                                    }
                                }
                            }
                        }
                        //根据类别id查询类别详情
                        MlccCategoryTestInfo leibiedatainfo1 = testparameterService.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                        if(leibiedatainfo1!=null){
                            MlccCategoryInfo zsleibie = parameterService.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),formalcategory_id,dingzhi1);
                            if(zsleibie!=null){
                                firstId = zsleibie.getId().toString();
                            }
                        }
                        String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                        String strbody="";
                        for (String s:canshuids){
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo2 = testparameterService.select_testcategoryDetail(s);
                            if(leibiedatainfo2!=null){
                                MlccCategoryInfo zsleibie = parameterService.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(),formalcategory_id,dingzhi2);
                                if(zsleibie!=null){
                                    strbody += zsleibie.getId().toString()+",";
                                }
                            }
                        }
                        secoundId = strbody.substring(0,strbody.length()-1);
                        //循环添加互斥
                        MutexTestInfo datainfo = new MutexTestInfo();
                        datainfo.setMutexName(huchilist.get(i).getMutexName());
                        datainfo.setTopId(formalcategory_id);
                        datainfo.setCategoryId(firstId);//第一个参数id
                        datainfo.setCategoryOther(secoundId);//第二个参数id
                        datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                        datainfo.setStatus(huchilist.get(i).getStatus());
                        datainfo.setCode(huchilist.get(i).getCode());
                        datainfo.setDingzhi1(dingzhi1);
                        datainfo.setDingzhi2(dingzhi2);
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code4 = parameterService.add_huchi(datainfo);
                    }
                }
                Long startTs2 = System.currentTimeMillis(); // 当前时间戳
                System.out.println("输出时间========"+(startTs2-startTs1));
                System.out.println("各个code=="+code2+"="+code3+"="+code4+"="+code5+"="+code6+"="+code66+"="+code7+"="+code8+"="+code9+"="+code10+"==67=="+code67);
                if(code2>0 || code3>0 || code4>0 || code5>0 || code6>0 || code66>0 || code67>0 || code7>0 || code8>0 || code9>0 || code10>0 || code11>0){
                    //测试区
                    parameterService.add_qiyong_record(category_id,"0","0",zhengshi_categoryName+" 【再次】 启用成为正式品类",create_by,sys_org_code);
                    //正式插入记录
                    parameterService.add_qiyong_record(formalcategory_id,"0","0","已由草稿件"+zhengshi_categoryName+" 【再次】 启用成为正式品类",create_by,sys_org_code);
                    parameterService.update_category_size(formalcategory_id,issize);//修改是否采用体型数据
                    //修改正式品类的状态---一开始启用为未上架
//                    parameterService.edit_category_status(formalcategory_id,"2");
                    return Result.ok("再次启用成功");
                }else {
                    return Result.error("启用失败");
                }

            }else {
                System.out.println("znewn编码====="+category_code);
                //赋值测试类别id
                testpinglei.setTestcategoryId(testpinglei.getId().toString());
                testpinglei.setIsSize(testpinglei.getIsSize());
                int code1 = parameterService.add_category_pinglei2(testpinglei);
                System.out.println("chengogn2===="+code1);
                int code2 = 0,code3=0,code4=0,code5=0,code6=0,code7=0,code8=0,code9=0,code10=0,code66=0,code11=0,code67=0;
                if(code1>0){
                    //根据品类id查询定制项
                    List<SmalltemplateTestInfo> dingzhilist = testparameterService.query_dingzhiBycategoryId(category_id);
                    //根据品类id查询定制项下的参数
                    List<MlccCategoryTestInfo> canshulist = parameterService.query_AllcanshuBypingleiId(category_id);
                    //根据品类id查询互斥项
                    List<MutexTestInfo> huchilist = parameterService.query_AllhuchiBypingleiId(category_id);
                    //根据品类id查询绣字部位
                    List<CategoryLocationTestInfo> xuzilist1 = parameterService.query_Allxiuzi1BypingleiId(category_id);
                    //根据品类id查询绣字颜色
                    List<EmbroideredColorTestInfo> xuzilist2 = parameterService.query_AllxiuziColorBypingleiId(category_id);
                    //根据品类id查询绣字图片
                    List<EmbroideredFontTestInfo> xuzilist3 = parameterService.query_AllxiuziFontBypingleiId(category_id);
                    //根据品类id查询撞色
                    List<ContrastcolorTestInfo> zhuangselist = parameterService.query_AllzhuangseBypingleiId(category_id);
                    //根据品类id查询净体尺寸
                    List<BodySizeTestInfo> bodysizelist1 = parameterService.query_AlljingtiBodysizeBypingleiId(category_id);
                    //根据品类id查询返修
                    List<CategoryFanxiuTestInfo> fanxiulist = parameterService.query_AllFanxiuBypingleiId(category_id);
                    //根据品类id查询工艺类型
                    List<MlccCategoryTestInfo> gongyilist = parameterService.query_AllGongyiBypingleiId(category_id);
                    //根据品类id查询系统加急---cesih
                    List<AddSystemPriceInfo> syspricelist = parameterService.query_AllsyspriceBypingleiId(category_id,1);
                    List<AddSystemPriceInfo> syspricelist2 = parameterService.query_AllsyspriceBypingleiId(category_id,0);
                    //根据品类id查询所有绣字高度-测试
                    List<EmbroidedHeightInfo> xiuziHeightlist = parameterService.query_AllxiuziHeightBypingleiId(category_id);

                    MlccCategoryInfo pingleiDetail = parameterService.select_zscategoryDetail(category_code);//根据品类编号查询品类
                    if(pingleiDetail!=null){
                        String zspingleiId = pingleiDetail.getId().toString();//正式品类id
                        zhengshi_categoryId = pingleiDetail.getId().toString();//正式品类id
                        zhengshi_categoryName = pingleiDetail.getCategoryName();
                        if(dingzhilist.size()>0){
                            for (int i=0;i<dingzhilist.size();i++){
                                //循环添加定制项
                                SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                                datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setCode(dingzhilist.get(i).getCode());
                                datainfo.setParameter(dingzhilist.get(i).getParameter());
                                datainfo.setImgs(dingzhilist.get(i).getImgs());
                                datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                                datainfo.setIstype(dingzhilist.get(i).getIstype());
                                datainfo.setRemark(dingzhilist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code2 = parameterService.add_dingzhi(datainfo);
                            }
                        }

                        if(canshulist.size()>0){
                            for (int i=0;i<canshulist.size();i++){
                                String praent_id = "";
                                SmalltemplateTestInfo ceshidingdatainfo = testparameterService.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                                if(ceshidingdatainfo!=null){
                                    //查询新增的定制项
                                    List<SmalltemplateTestInfo> zsdingzhi_datalist = parameterService.query_dingzhiBycategoryId(zspingleiId);
                                    if(zsdingzhi_datalist.size()>0){
                                       for (int k=0;k<zsdingzhi_datalist.size();k++){
                                           if(ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                               praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                           }
                                       }
                                    }
                                }
                                //循环添加定制项下的参数
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                                datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                                datainfo.setParentId(praent_id);//正式的上级id
                                datainfo.setImg(canshulist.get(i).getImg());
                                datainfo.setTopid(zspingleiId);
                                datainfo.setNumbers(canshulist.get(i).getNumbers());
                                datainfo.setIsType(canshulist.get(i).getIsType());
                                datainfo.setCost(canshulist.get(i).getCost());
                                datainfo.setTeamPrice2(canshulist.get(i).getTeamPrice2());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code3 = parameterService.add_dingzhi_canshu(datainfo);
                            }
                        }
                        if(huchilist.size()>0){
                            for (int i=0;i<huchilist.size();i++){
                                //查询新增的定制项
                                String dingzhi1="",dingzhi2="";
                                String firstId = "",secoundId="";
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = parameterService.query_dingzhiBycategoryId(zspingleiId);
                                SmalltemplateTestInfo ceshidingdatainfo1 = testparameterService.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                                SmalltemplateTestInfo ceshidingdatainfo2 = testparameterService.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                                if(ceshidingdatainfo1!=null){
                                    if(zsdingzhi_datalist.size()>0){
                                        for (int k=0;k<zsdingzhi_datalist.size();k++){
                                            if(ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                                dingzhi1 = zsdingzhi_datalist.get(k).getId().toString();
                                                break;
                                            }
                                        }
                                    }
                                }
                                if(ceshidingdatainfo2!=null){
                                    if(zsdingzhi_datalist.size()>0){
                                        for (int k=0;k<zsdingzhi_datalist.size();k++){
                                            if(ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                                dingzhi2 = zsdingzhi_datalist.get(k).getId().toString();
                                                break;
                                            }
                                        }
                                    }
                                }
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo1 = testparameterService.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                                if(leibiedatainfo1!=null){
                                    MlccCategoryInfo zsleibie = parameterService.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),zspingleiId,dingzhi1);
                                    if(zsleibie!=null){
                                        firstId = zsleibie.getId().toString();
                                    }
                                }
                                String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                                String strbody="";
                                for (String s:canshuids){
                                    //根据类别id查询类别详情
                                    MlccCategoryTestInfo leibiedatainfo2 = testparameterService.select_testcategoryDetail(s);
                                    if(leibiedatainfo2!=null){
                                        MlccCategoryInfo zsleibie = parameterService.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(),zspingleiId,dingzhi2);
                                        if(zsleibie!=null){
                                            strbody += zsleibie.getId().toString()+",";
                                        }
                                    }
                                }
                                secoundId = strbody.substring(0,strbody.length()-1);
                                //循环添加互斥
                                MutexTestInfo datainfo = new MutexTestInfo();
                                datainfo.setMutexName(huchilist.get(i).getMutexName());
                                datainfo.setTopId(zspingleiId);
                                datainfo.setCategoryId(firstId);
                                datainfo.setCategoryOther(secoundId);
                                datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                                datainfo.setStatus(huchilist.get(i).getStatus());
                                datainfo.setCode(huchilist.get(i).getCode());
                                datainfo.setDingzhi1(dingzhi1);
                                datainfo.setDingzhi2(dingzhi2);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code4 = parameterService.add_huchi(datainfo);
                            }
                        }
                        if(xuzilist1.size()>0){
                            for (int i=0;i<xuzilist1.size();i++){
                                //循环添加绣字部位
                                CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                                datainfo.setCode(xuzilist1.get(i).getCode());
                                datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setRemark(xuzilist1.get(i).getRemark());
                                datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code5 = parameterService.add_xiuzi_location(datainfo);
                            }
                        }
                        if(xuzilist2.size()>0){
                            for (int i=0;i<xuzilist2.size();i++){
                                //循环添加绣字颜色
                                EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                                datainfo.setCode(xuzilist2.get(i).getCode());
                                datainfo.setColorName(xuzilist2.get(i).getColorName());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                                datainfo.setRemark(xuzilist2.get(i).getRemark());
                                datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code6 = parameterService.add_xiuzi_color(datainfo);
                            }
                        }
                        if(xuzilist3.size()>0){
                            for (int i=0;i<xuzilist3.size();i++){
                                //循环添加绣字字体
                                EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                                datainfo.setCode(xuzilist3.get(i).getCode());
                                datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                                datainfo.setRemark(xuzilist3.get(i).getRemark());
                                datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                                datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                                datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code66 = parameterService.add_xiuzi_fontImg(datainfo);
                            }
                        }
                        if(xiuziHeightlist.size()>0){
                            for (int i=0;i<xiuziHeightlist.size();i++){
                                //循环添加绣字高度
                                EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                                datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                                datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code67 = banhao_parameterService.add_xiuzi_height(datainfo);
                            }
                        }
                        if(zhuangselist.size()>0){
                            for (int i=0;i<zhuangselist.size();i++){
                                String praent_id = "",firstId="";
                                SmalltemplateTestInfo ceshidingdatainfo = testparameterService.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                                if(ceshidingdatainfo!=null){
                                    //查询新增的定制项
                                    List<SmalltemplateTestInfo> zsdingzhi_datalist = parameterService.query_dingzhiBycategoryId(zspingleiId);
                                    if(zsdingzhi_datalist.size()>0){
                                        for (int k=0;k<zsdingzhi_datalist.size();k++){
                                            if(ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                                praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                            }
                                        }
                                    }
                                }
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo1 = testparameterService.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                                if(leibiedatainfo1!=null){
                                    MlccCategoryInfo zsleibie = parameterService.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),zspingleiId,praent_id);
                                    if(zsleibie!=null){
                                        firstId = zsleibie.getId().toString();
                                    }
                                }
                                //循环添加撞色
                                ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                                datainfo.setTopId(zspingleiId);
                                datainfo.setCode(zhuangselist.get(i).getCode());
                                datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                                datainfo.setCategoryId(firstId);
                                datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                                datainfo.setDingzhiId(praent_id);
                                datainfo.setRemark(zhuangselist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code7 = parameterService.add_zhuangse(datainfo);
                            }
                        }
                        if(bodysizelist1.size()>0){
                            for (int i=0;i<bodysizelist1.size();i++){
                                //循环添加身体尺寸
                                BodySizeTestInfo datainfo = new BodySizeTestInfo();
                                datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                                datainfo.setUnit(bodysizelist1.get(i).getUnit());
                                datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                                datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                                datainfo.setMax(bodysizelist1.get(i).getMax());
                                datainfo.setMin(bodysizelist1.get(i).getMin());
                                datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code8 = parameterService.add_testbodySize(datainfo);
                            }
                        }
                        if(fanxiulist.size()>0){
                            for (int i=0;i<fanxiulist.size();i++){
                                //循环添加返修
                                CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                                datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                                datainfo.setUnit(fanxiulist.get(i).getUnit());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                                datainfo.setMax(fanxiulist.get(i).getMax());
                                datainfo.setMin(fanxiulist.get(i).getMin());
                                datainfo.setRemark(fanxiulist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code9 = parameterService.add_testFanxiuSize(datainfo);
                            }
                        }
                        if(syspricelist.size()>0){
                            for (int i=0;i<syspricelist.size();i++){
                                //循环添加系统加急--上级
                                AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                                datainfo.setPremiumItem(syspricelist.get(i).getPremiumItem());
                                datainfo.setPremiumCode(syspricelist.get(i).getPremiumCode());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setType(syspricelist.get(i).getType());
                                datainfo.setRemark(syspricelist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setPartentId("0");
                                datainfo.setIsTop(1);
                                datainfo.setNumbers(syspricelist.get(i).getNumbers());
                                code11 = parameterService.add_fomal_syspriceinfo(datainfo);
                            }
                        }

                        if(syspricelist2.size()>0){
                            for (int i=0;i<syspricelist2.size();i++){
                                //根据编码查询系统加急项
                                String praent_id = "";
                                AddSystemPriceInfo ceshidingdatainfo = testparameterService.query_addsyspriceDetail(syspricelist2.get(i).getPartentId());
                                if(ceshidingdatainfo!=null){
                                    //查询新增的上级加急项
                                    List<AddSystemPriceInfo> zsdingzhi_datalist = banhao_parameterService.query_AllsyspriceBypingleiId(zspingleiId,1);
                                    if(zsdingzhi_datalist.size()>0){
                                        for (int k=0;k<zsdingzhi_datalist.size();k++){
                                            if(ceshidingdatainfo.getPremiumCode().equals(zsdingzhi_datalist.get(k).getPremiumCode())){
                                                praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                                break;
                                            }
                                        }
                                    }
                                }
                                //循环添加系统加急--下级
                                AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                                datainfo.setPremiumItem(syspricelist2.get(i).getPremiumItem());
                                datainfo.setPremiumCode(syspricelist2.get(i).getPremiumCode());
                                datainfo.setCategoryId(zspingleiId);
                                datainfo.setType(syspricelist2.get(i).getType());
                                datainfo.setRemark(syspricelist2.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setPartentId(praent_id);//上级
                                datainfo.setIsTop(0);
                                datainfo.setNumbers(syspricelist2.get(i).getNumbers());
                                code11 = parameterService.add_fomal_syspriceinfo(datainfo);
                            }
                        }

                        if(gongyilist.size()>0){
                            for (int i=0;i<gongyilist.size();i++){
                                //循环添加工艺
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                                datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                                datainfo.setParentId(gongyilist.get(i).getParentId());
                                datainfo.setImg(gongyilist.get(i).getImg());
                                datainfo.setRemark(gongyilist.get(i).getRemark());
                                datainfo.setTopid(zspingleiId);
                                datainfo.setIsType(4);
                                datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                                datainfo.setNumbers(gongyilist.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code10 = parameterService.add_category_pinglei2(datainfo);
                                if(code10>0){
                                    MlccCategoryInfo gongyidetail = parameterService.select_zscategoryDetail2(gongyilist.get(i).getCategoryCode(),zspingleiId);//根据品类编号查询品类
                                    if(gongyidetail!=null){
                                        for (int j=0;j<3;j++){
                                            parameterService.add_pricesystem_category(gongyidetail.getId().toString(),j+"","工艺类型售价加工","1",
                                                    create_by,sys_org_code);
                                        }
                                    }
                                }

                            }
                        }
                    }
                    System.out.println("各个code=="+code2+"="+code3+"="+code4+"="+code5+"="+code6+"="+code66+"="+code7+"="+code8+"="+code9+"="+code10);
                    if(code2>0 || code3>0 || code4>0 || code5>0 || code6>0 || code66>0 || code67>0 || code7>0 || code8>0 || code9>0 || code10>0 || code11>0){
                        //测试区
                        parameterService.add_qiyong_record(category_id,"0","0",zhengshi_categoryName+"正式启用成为正式品类",create_by,sys_org_code);
                        //正式插入记录
                        parameterService.add_qiyong_record(zhengshi_categoryId,"0","0","已由草稿件"+zhengshi_categoryName+"正式启用成为正式品类",create_by,sys_org_code);
                        //修改正式品类的状态---一开始启用为未上架
                        parameterService.edit_category_status(zhengshi_categoryId,"2");
                        for (int j=0;j<3;j++){
                            parameterService.add_pricesystem_category(zhengshi_categoryId,j+"","品类成本项加工","0",
                                    create_by,sys_org_code);
                        }
                        return Result.ok("启用成功");
                    }else {
                        return Result.ok("启用成功，但要添加数据额");
                    }
                }else {
                    return Result.error("启用失败");
                }
            }
//        }catch (Exception e){
//            System.out.println("错误啦+="+e.toString());
//            return Result.error("失败，参数错误");
//        }
    }


    /**
     * 正式品类还原-成草稿件
     * @param
     * @return boolean
     */
    @PostMapping(value = "/right_restore_caogao")
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    public Result<?> right_restore_caogao(@RequestBody Map<String,Object> params) {
        String testcategory_id = params.get("category_id").toString();//获取测试品类id
        System.out.println("品类启用传的测试品类id===" + testcategory_id);
        //获取登录用户信息
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String sys_org_code = sysUser.getOrgCode();
        String create_by = sysUser.getUsername();
        String pingleiName = "",formal_categoryId="";
//        try {
        //查询正式的品类详情
        MlccCategoryInfo formalpinglei = parameterService.select_formal_categoryDetail(testcategory_id);//根据测试品类id查询正式品类
        if (formalpinglei != null) {
            pingleiName = formalpinglei.getCategoryName();
            formal_categoryId = formalpinglei.getId().toString();
            /**正式品类id下的参数*/
            String category_id = formalpinglei.getId().toString();
            System.out.println("查询到正式品类地=="+category_id);
            //根据品类id查询定制项
            List<SmalltemplateTestInfo> dingzhilist = banhao_parameterService.query_dingzhiBycategoryId(category_id);
            //根据品类id查询定制项下的参数
            List<MlccCategoryTestInfo> canshulist = banhao_parameterService.query_AllcanshuBypingleiId(category_id);
            //根据品类id查询互斥项
            List<MutexTestInfo> huchilist = banhao_parameterService.query_AllhuchiBypingleiId(category_id);
            //根据品类id查询绣字部位
            List<CategoryLocationTestInfo> xuzilist1 = banhao_parameterService.query_Allxiuzi1BypingleiId(category_id);
            //根据品类id查询绣字颜色
            List<EmbroideredColorTestInfo> xuzilist2 = banhao_parameterService.query_AllxiuziColorBypingleiId(category_id);
            //根据品类id查询绣字图片
            List<EmbroideredFontTestInfo> xuzilist3 = banhao_parameterService.query_AllxiuziFontBypingleiId(category_id);
            //根据品类id查询撞色
            List<ContrastcolorTestInfo> zhuangselist = banhao_parameterService.query_AllzhuangseBypingleiId(category_id);
            //根据品类id查询净体尺寸
            List<BodySizeTestInfo> bodysizelist1 = banhao_parameterService.query_AlljingtiBodysizeBypingleiId(category_id);
            //根据品类id查询返修
            List<CategoryFanxiuTestInfo> fanxiulist = banhao_parameterService.query_AllFanxiuBypingleiId(category_id);
            //根据品类id查询工艺类型
            List<MlccCategoryTestInfo> gongyilist = banhao_parameterService.query_AllGongyiBypingleiId(category_id);
            //根据品类id查询所有绣字高度
            List<EmbroidedHeightInfo> xiuziHeightlist = banhao_parameterService.query_AllHeightBypingleiId(category_id);
            //根据品类id查询所有的收费项
            List<AddSystemPriceInfo> shoufeilist = banhao_parameterService.query_AllsyspriceBypingleiId(category_id,1);
            //根据品类id查询所有的收费项
            List<AddSystemPriceInfo> shoufeilist2 = banhao_parameterService.query_AllsyspriceBypingleiId(category_id,0);


            /**根据测试品类id查询测试数据*/
            //根据品类id查询定制项
            List<SmalltemplateTestInfo> test_dingzhilist = testparameterService.query_dingzhiBycategoryId(testcategory_id);
            //根据品类id查询定制项下的参数
            List<MlccCategoryTestInfo> test_canshulist = parameterService.query_AllcanshuBypingleiId(testcategory_id);
            //根据品类id查询互斥项
            List<MutexTestInfo> test_huchilist = parameterService.query_AllhuchiBypingleiId(testcategory_id);
            //根据品类id查询绣字部位
            List<CategoryLocationTestInfo> test_xuzilist1 = parameterService.query_Allxiuzi1BypingleiId(testcategory_id);
            //根据品类id查询绣字颜色
            List<EmbroideredColorTestInfo> test_xuzilist2 = parameterService.query_AllxiuziColorBypingleiId(testcategory_id);
            //根据品类id查询绣字图片
            List<EmbroideredFontTestInfo> test_xuzilist3 = parameterService.query_AllxiuziFontBypingleiId(testcategory_id);
            //根据品类id查询撞色
            List<ContrastcolorTestInfo> test_zhuangselist = parameterService.query_AllzhuangseBypingleiId(testcategory_id);
            //根据品类id查询净体尺寸
            List<BodySizeTestInfo> test_bodysizelist1 = parameterService.query_AlljingtiBodysizeBypingleiId(testcategory_id);
            //根据品类id查询返修
            List<CategoryFanxiuTestInfo> test_fanxiulist = parameterService.query_AllFanxiuBypingleiId(testcategory_id);
            //根据品类id查询工艺类型
            List<MlccCategoryTestInfo> test_gongyilist = parameterService.query_AllGongyiBypingleiId(testcategory_id);
            //根据品类id查询所有绣字高度-测试
            List<EmbroidedHeightInfo> test_xiuziHeightlist = parameterService.query_AllxiuziHeightBypingleiId(category_id);

            //根据品类id查询系统加急---cesih
            List<AddSystemPriceInfo> test_shoufeilist = parameterService.query_AllsyspriceBypingleiId(category_id,1);
            List<AddSystemPriceInfo> test_shoufeilist2 = parameterService.query_AllsyspriceBypingleiId(category_id,0);

//            //根据品类id查询所有的收费项-测试
//            List<AddSystemPriceInfo> test_shoufeilist = banhao_parameterService.query_AllAddSystemPriceBypingleiId(category_id,2);
//            //根据品类id查询所有的收费项-测试
//            List<AddSystemPriceInfo> test_shoufeilist2 = banhao_parameterService.query_AllAddSystemPriceBypingleiId(category_id,0);


            if (test_canshulist.size() > 0) {
                //循环删除
                int code = 0;
                for (MlccCategoryTestInfo testobject : test_canshulist) {
                    code = testparameterService.delete_dingzhi_canshu(testobject.getId().toString());
                }
                System.out.println("删除参数==" + code);
            }
            if (test_dingzhilist.size() > 0) {
                //循环删除
                int code = 0;
                for (SmalltemplateTestInfo testobject : test_dingzhilist) {
                    code = testparameterService.delete_dingzhi(testobject.getId().toString());
                }
                System.out.println("删除定制项==" + code);
            }
            if (test_huchilist.size() > 0) {
                //循环删除
                int code = 0;
                for (MutexTestInfo testobject : test_huchilist) {
                    code = testparameterService.delete_huchi(testobject.getId().toString());
                }
                System.out.println("删除互斥项==" + code);
            }
            if (test_xuzilist1.size() > 0) {
                //循环删除
                int code = 0;
                for (CategoryLocationTestInfo testobject : test_xuzilist1) {
                    code = testparameterService.delete_xiuzi_location(testobject.getId().toString());
                }
                System.out.println("删除绣字部位==" + code);
            }
            if (test_xuzilist2.size() > 0) {
                //循环删除
                int code = 0;
                for (EmbroideredColorTestInfo testobject : test_xuzilist2) {
                    code = testparameterService.delete_xiuzi_color(testobject.getId().toString());
                }
                System.out.println("删除绣字颜色==" + code);
            }
            if (test_xuzilist3.size() > 0) {
                //循环删除
                int code = 0;
                for (EmbroideredFontTestInfo testobject : test_xuzilist3) {
                    code = testparameterService.delete_xiuzi_fontImg(testobject.getId().toString());
                }
                System.out.println("删除绣字字体图片==" + code);
            }
            if (test_xiuziHeightlist.size() > 0) {
                //循环删除
                int code = 0;
                for (EmbroidedHeightInfo testobject : test_xiuziHeightlist) {
                    code = testparameterService.delete_xiuzi_height(testobject.getId().toString());
                }
                System.out.println("删除绣字高度==" + code);
            }
            if (test_zhuangselist.size() > 0) {
                //循环删除
                int code = 0;
                for (ContrastcolorTestInfo testobject : test_zhuangselist) {
                    code = testparameterService.delete_zhuangse(testobject.getId().toString());
                }
                System.out.println("删除撞色==" + code);
            }
            if (test_bodysizelist1.size() > 0) {
                //循环删除
                int code = 0;
                for (BodySizeTestInfo testobject : test_bodysizelist1) {
                    code = testparameterService.delete_testbodySize(testobject.getId().toString());
                }
                System.out.println("删除尺寸==" + code);
            }
            if (test_fanxiulist.size() > 0) {
                //循环删除
                int code = 0;
                for (CategoryFanxiuTestInfo testobject : test_fanxiulist) {
                    code = testparameterService.delete_testfanxiuSize(testobject.getId().toString());
                }
                System.out.println("删除返修==" + code);
            }
            if (test_gongyilist.size() > 0) {
                //循环删除
                int code = 0;
                for (MlccCategoryTestInfo testobject : test_gongyilist) {
                    code = testparameterService.delete_testcategory(testobject.getId().toString());
                }
                System.out.println("删除工艺类型==" + code);
            }

            if (test_shoufeilist.size() > 0) {
                //循环删除
                int code = 0;
                for (AddSystemPriceInfo testobject : test_shoufeilist) {
                    code = testparameterService.delete_addsysytemprice(testobject.getId().toString());
                }
                System.out.println("删除收费项==" + code);
            }
            if (test_shoufeilist2.size() > 0) {
                //循环删除
                int code = 0;
                for (AddSystemPriceInfo testobject : test_shoufeilist2) {
                    code = testparameterService.delete_addsysytemprice(testobject.getId().toString());
                }
                System.out.println("删除收费项==" + code);
            }

            /**
             * 添加到测试表的数据
             * */
            int code2 = 0, code3 = 0, code4 = 0, code5 = 0, code6 = 0, code7 = 0, code8 = 0, code9 = 0, code10 = 0, code66 = 0,code67 = 0,code11=0;
            if (dingzhilist.size() > 0) {
                for (int i = 0; i < dingzhilist.size(); i++) {
                    //循环添加定制项
                    SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                    datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setCode(dingzhilist.get(i).getCode());
                    datainfo.setParameter(dingzhilist.get(i).getParameter());
                    datainfo.setImgs(dingzhilist.get(i).getImgs());
                    datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                    datainfo.setIstype(dingzhilist.get(i).getIstype());
                    datainfo.setRemark(dingzhilist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code2 = testparameterService.add_dingzhi(datainfo);
                }
            }
            if (canshulist.size() > 0) {
                for (int i = 0; i < canshulist.size(); i++) {
                    String praent_id = "";
                    SmalltemplateTestInfo ceshidingdatainfo = parameterService.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                    if (ceshidingdatainfo != null) {
                        //查询新增的定制项
                        List<SmalltemplateTestInfo> zsdingzhi_datalist = testparameterService.query_dingzhiBycategoryId(testcategory_id);
                        if (zsdingzhi_datalist.size() > 0) {
                            for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                    praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                }
                            }
                        }
                    }
                    //循环添加定制项下的参数
                    MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                    datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                    datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                    datainfo.setParentId(praent_id);//测试的上级id
                    datainfo.setImg(canshulist.get(i).getImg());
                    datainfo.setTopid(testcategory_id);
                    datainfo.setNumbers(canshulist.get(i).getNumbers());
                    datainfo.setIsType(canshulist.get(i).getIsType());
                    datainfo.setCost(canshulist.get(i).getCost());
                    datainfo.setTeamPrice2(canshulist.get(i).getTeamPrice2());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code3 = testparameterService.add_dingzhi_canshu(datainfo);
                }
            }
            if (huchilist.size() > 0) {
                for (int i = 0; i < huchilist.size(); i++) {
                    //循环添加互斥
                    MutexTestInfo datainfo = new MutexTestInfo();
                    datainfo.setMutexName(huchilist.get(i).getMutexName());
                    datainfo.setTopId(testcategory_id);
                    datainfo.setCategoryId(huchilist.get(i).getCategoryId());
                    datainfo.setCategoryOther(huchilist.get(i).getCategoryOther());
                    datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                    datainfo.setStatus(huchilist.get(i).getStatus());
                    datainfo.setCode(huchilist.get(i).getCode());
                    datainfo.setDingzhi1(huchilist.get(i).getDingzhi1());
                    datainfo.setDingzhi2(huchilist.get(i).getDingzhi2());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code4 = testparameterService.add_huchi(datainfo);
                }
            }
            if (xuzilist1.size() > 0) {
                for (int i = 0; i < xuzilist1.size(); i++) {
                    //循环添加绣字部位
                    CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                    datainfo.setCode(xuzilist1.get(i).getCode());
                    datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setRemark(xuzilist1.get(i).getRemark());
                    datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code5 = testparameterService.add_xiuzi_location(datainfo);
                }
            }
            if (xuzilist2.size() > 0) {
                for (int i = 0; i < xuzilist2.size(); i++) {
                    //循环添加绣字颜色
                    EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                    datainfo.setCode(xuzilist2.get(i).getCode());
                    datainfo.setColorName(xuzilist2.get(i).getColorName());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                    datainfo.setRemark(xuzilist2.get(i).getRemark());
                    datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code6 = testparameterService.add_xiuzi_color(datainfo);
                }
            }
            if (xuzilist3.size() > 0) {
                for (int i = 0; i < xuzilist3.size(); i++) {
                    //循环添加绣字字体
                    EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                    datainfo.setCode(xuzilist3.get(i).getCode());
                    datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                    datainfo.setRemark(xuzilist3.get(i).getRemark());
                    datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                    datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                    datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code66 = testparameterService.add_xiuzi_fontImg(datainfo);
                }
            }
            if(xiuziHeightlist.size()>0){
                for (int i=0;i<xiuziHeightlist.size();i++){
                    //循环添加绣字高度
                    EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                    datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                    datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code67 = testparameterService.add_xiuzi_height(datainfo);
                }
            }
            if (zhuangselist.size() > 0) {
                for (int i = 0; i < zhuangselist.size(); i++) {
                    //循环添加撞色
                    ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                    datainfo.setTopId(testcategory_id);
                    datainfo.setCode(zhuangselist.get(i).getCode());
                    datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                    datainfo.setCategoryId(zhuangselist.get(i).getCategoryId());
                    datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                    datainfo.setSinglePrice2(zhuangselist.get(i).getSinglePrice2());
                    datainfo.setTeamPrice2(zhuangselist.get(i).getTeamPrice2());
                    datainfo.setDingzhiId(zhuangselist.get(i).getDingzhiId());
                    datainfo.setRemark(zhuangselist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code7 = testparameterService.add_zhuangse(datainfo);
                }
            }
            if (bodysizelist1.size() > 0) {
                for (int i = 0; i < bodysizelist1.size(); i++) {
                    //循环添加身体尺寸
                    BodySizeTestInfo datainfo = new BodySizeTestInfo();
                    datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                    datainfo.setUnit(bodysizelist1.get(i).getUnit());
                    datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                    datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                    datainfo.setMax(bodysizelist1.get(i).getMax());
                    datainfo.setMin(bodysizelist1.get(i).getMin());
                    datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setCode(bodysizelist1.get(i).getCode());
                    code8 = testparameterService.add_testbodySize(datainfo);
                }
            }
            if (fanxiulist.size() > 0) {
                for (int i = 0; i < fanxiulist.size(); i++) {
                    //循环添加返修
                    CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                    datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                    datainfo.setUnit(fanxiulist.get(i).getUnit());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                    datainfo.setMax(fanxiulist.get(i).getMax());
                    datainfo.setMin(fanxiulist.get(i).getMin());
                    datainfo.setRemark(fanxiulist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setCode(fanxiulist.get(i).getCode());
                    code9 = testparameterService.add_testFanxiuSize(datainfo);
                }
            }
            if (gongyilist.size() > 0) {
                for (int i = 0; i < gongyilist.size(); i++) {
                    //循环添加工艺
                    MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                    datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                    datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                    datainfo.setParentId("4");
                    datainfo.setImg(gongyilist.get(i).getImg());
                    datainfo.setRemark(gongyilist.get(i).getRemark());
                    datainfo.setTopid(testcategory_id);
                    datainfo.setIsType(4);
                    datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                    datainfo.setNumbers(gongyilist.get(i).getNumbers());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code10 = testparameterService.add_category_pinglei(datainfo);
                }
            }
            if (shoufeilist.size() > 0) {
                for (int i = 0; i < shoufeilist.size(); i++) {
                    //循环添加收费
                    AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                    datainfo.setPremiumItem(shoufeilist.get(i).getPremiumItem());
                    datainfo.setPremiumCode(shoufeilist.get(i).getPremiumCode());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setType(shoufeilist.get(i).getType());
                    datainfo.setRemark(shoufeilist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setPartentId("0");
                    datainfo.setIsTop(1);
                    datainfo.setNumbers(shoufeilist.get(i).getNumbers());
                    code11 = testparameterService.add_addsysytemprice(datainfo);
                }
            }
            if(shoufeilist2.size()>0){
                for (int i=0;i<shoufeilist2.size();i++){
                    //根据编码查询系统加急项
                    String praent_id = "";
                    AddSystemPriceInfo ceshidingdatainfo = parameterService.query_addsyspriceDetail(shoufeilist2.get(i).getPartentId());
                    if(ceshidingdatainfo!=null){
                        //查询新增的上级加急项
                        List<AddSystemPriceInfo> zsdingzhi_datalist = parameterService.query_AllsyspriceBypingleiId(testcategory_id,1);
                        if(zsdingzhi_datalist.size()>0){
                            for (int k=0;k<zsdingzhi_datalist.size();k++){
                                if(ceshidingdatainfo.getPremiumCode().equals(zsdingzhi_datalist.get(k).getPremiumCode())){
                                    praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                    break;
                                }
                            }
                        }
                    }
                    //循环添加系统加急--下级
                    AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                    datainfo.setPremiumItem(shoufeilist2.get(i).getPremiumItem());
                    datainfo.setPremiumCode(shoufeilist2.get(i).getPremiumCode());
                    datainfo.setCategoryId(testcategory_id);
                    datainfo.setType(shoufeilist2.get(i).getType());
                    datainfo.setRemark(shoufeilist2.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setPartentId(praent_id);//上级
                    datainfo.setIsTop(0);
                    datainfo.setNumbers(shoufeilist2.get(i).getNumbers());
                    code11 = parameterService.add_fomal_syspriceinfo(datainfo);
                }
            }


            System.out.println("各个code=="+code2+"="+code3+"="+code4+"="+code5+"="+code6+"="+code66+"="+code7+"="+code8+"="+code9+"="+code10);
            if(code2>0 || code3>0 || code4>0 || code5>0 || code6>0 || code66>0 || code67>0 || code7>0 || code8>0 || code9>0 || code10>0 || code11>0){
                //测试区
                parameterService.add_qiyong_record(testcategory_id,"0","1",pingleiName+"被还原成草稿件",create_by,sys_org_code);
                //正式插入记录
                parameterService.add_qiyong_record(formal_categoryId,"0","1",pingleiName+"已还原成草稿件",create_by,sys_org_code);
                return Result.ok("还原草稿件成功");
            }else {
                return Result.error("还原草稿件失败");
            }
        }else {
            return Result.error("该品类暂未启用过，不能还原，请先启用");
        }
//        }catch (Exception e){
//            return Result.error("失败，参数错误");
//        }
    }


//    /**
//     * 总后台查询+正式的类别的加急服务
//     * @param pageNo
//     * @param pageSize
//     * @return
//     */
//    @GetMapping(value = "/category_addprice_list")
//    public Result<?> category_addprice_list(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
//                                            @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
//                                            String category_id,String queryName,String queryTime) {
//        Page<AddSystemPriceInfo> page = new Page<AddSystemPriceInfo>(pageNo, pageSize);
//        IPage<AddSystemPriceInfo> pageList = parameterService.query_addpricePageList(page,category_id,queryName,queryTime);
//        return Result.ok(pageList);
//    }

    /**
     * 总后台查询+测试绣字高度列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/test_xiuzi_hegihtlist")
    public Result<?> test_xiuzi_hegihtlist(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                           @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                           String category_id,String queryName,String queryTime) {
        Page<EmbroidedHeightInfo> page = new Page<EmbroidedHeightInfo>(pageNo, pageSize);
        IPage<EmbroidedHeightInfo> pageList = parameterService.query_testHeightPageList(page,category_id,queryName,queryTime);
        return Result.ok(pageList);
    }

    /**
     * 总后台查询+类别的加急服务
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/category_addprice_list")
    public Result<?> category_addprice_list(@RequestParam(name="pageNo", defaultValue="1") final Integer pageNo,
                                            @RequestParam(name="pageSize", defaultValue="10") final Integer pageSize,
                                            String category_id,String partent_id,String queryName,String queryTime) {
        Page<AddSystemPriceInfo> page = new Page<AddSystemPriceInfo>(pageNo, pageSize);
        IPage<AddSystemPriceInfo> pageList = parameterService.query_addpricePageList(page,category_id,partent_id,queryName,queryTime);
        return Result.ok(pageList);
    }

    /**
     * 根据id查询收费项
     * @return
     */
    @GetMapping(value = "/query_syspriceByid")
    public Result<?> query_syspriceByid(@RequestParam(name="dinghzi_id")String dinghzi_id){
        AddSystemPriceInfo datainfo = parameterService.query_addsyspriceDetail(dinghzi_id);
        if(datainfo!=null){
            return Result.ok(datainfo);
        }else{
            return Result.error("未找到对应数据");
        }
    }
    /**
     * 查询所有加价项服务-上级
     * @return
     */
    @GetMapping(value = "/query_all_topaddsysprice")
    public Result<?> query_all_topaddsysprice(@RequestParam(name="category_id")String category_id){
        List<AddSystemPriceInfo> datalist= parameterService.query_alladdsysprice(category_id);
        if(datalist.size()>0){
            return Result.ok(datalist);
        }else{
            return Result.error("未找到对应数据");
        }
    }

}
